package com.iman.manjusri.web;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.iman.common.util.ConfigUtil;

@Controller
@RequestMapping(value="/test/*")
public class JspPageController extends BaseController{
	
	// 其他的页面模仿我的请求，  返回 "email_suc";  就能显示 jsp页面
	@RequestMapping(value="/email_suc")
	public String initjsp(){
		return "email_suc";
	}
	
	// 其他的页面模仿我的请求，  返回 "email_suc";  就能显示 jsp页面
	@RequestMapping(value="/email")
	public ModelAndView initjspParamter(HttpServletRequest request){
		Map model = new HashMap();
		ModelAndView view =null;
		if(  1>8){
			view = new ModelAndView("email_suc",model);
		}else {
			view = new ModelAndView("testemail_suc",model);
		}
		return view;
	}
	
	/**
	 * 
	 * image.server = http://127.0.0.1:808/

css.server =  http://127.0.0.1:808/
	 * 
	 * 
	 * 
	 * @return
	 */
	
	
	//这个是 输入 freemarker 的模板例子
	@RequestMapping(value="/initftl")
	public String initftl(){
		return "email_sucftl";
	}
	
	
	//这个是 输入 freemarker 的模板例子
	@RequestMapping(value="/information")
	public ModelAndView initftlParamter(HttpServletRequest request){
		Map model = new HashMap();
		model.put("user", "测试传递变量" );
		System.out.println("request.getContextPath()::::"+request.getContextPath());
		model.put("pageSize",10 );
		model.put("pageCount", 50 );
		model.put("pageIndex", 4 );
		ModelAndView view =null;
		view = new ModelAndView("test/information_list",model);
		//公共资源 
		putResourceSrc(view);	
		return view;
	}
	
	
	//这个是 输入 freemarker 的模板例子
		@RequestMapping(value="/information/{pageIndex}")
		public ModelAndView pageftlParamter(HttpServletRequest request, @Valid    @PathVariable  	String	pageIndex){
			System.out.println("request.getContextPath()::::"+request.getRequestURI());
			Map model = new HashMap();
			model.put("user", "测试传递变量" );
			
			int page_Index = NumberUtils.toInt(pageIndex,1);
			//我们所有的  每页多少个都是后台写死了， 默认10个，没有特殊情况就这样了
			//每点击一次，也没重新  location 刷新
			model.put("pageSize",10 );
			model.put("pageCount", 50 );
			model.put("pageIndex", page_Index );
			
			model.put("pagePath", "/test/information/" );
			ModelAndView view =null;
			view = new ModelAndView("test/information_list",model);
			//公共资源 
			putResourceSrc(view);	
			return view;
		}
	
}
